﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lfm.EndPoints
{
    public class Event
    {
        /// <summary>
        /// Get the metadata for an event on Last.fm. Includes attendance and lineup information.
        /// </summary>
        /// <param name="ID">Get the metadata for an event on Last.fm. Includes attendance and lineup information.</param>
        /// <returns>lfm.Event</returns>
        public static async Task<lfm.Event> getInfo(Int64 ID)
        {
            String s = String.Format("{0}&method=event.getInfo&event={1}", Base.APIUrl, Uri.EscapeDataString(ID.ToString()));

            Uri u = new Uri(s, UriKind.RelativeOrAbsolute);
            return await Parser.Event.getInfo(await Base.DownloadString(u)); ;
        }

        /// <summary>
        /// Get shouts for this event. 
        /// </summary>
        /// <param name="Event">The numeric last.fm event id</param>
        /// <param name="Page">The page number to fetch. Defaults to first page.</param>
        /// <param name="Limit">The number of results to fetch per page. Defaults to 50.</param>
        /// <returns>List of lfm.Shout</returns>
        public static async Task<List<lfm.Shout>> getShouts(Int64 Event, Int32? Page, Int32? Limit)
        {
            String s = String.Format("{0}&method=event.getShouts&event={1}", Base.APIUrl, Uri.EscapeDataString(Event.ToString()));
            if (Page.HasValue) s += "&page=" + Page.Value.ToString();
            if (Limit.HasValue) s += "&limit=" + Limit.Value.ToString();

            Uri u = new Uri(s, UriKind.RelativeOrAbsolute);
            return await Parser.Generic.getShouts(await Base.DownloadString(u)); ;
        }
    }
}
